package com.ruoyi.prod.entity.po;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.OrderBy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.prod.entity.query.BaseCondition;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 基础字段
 *
 * @author BaiBan
 * @since 2023/2/16
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class BaseEntity extends BaseCondition implements Serializable {

    @ApiModelProperty(value = "删除标志", name = "delFlag", required = true, example = "删除标志0.未删除1.已删除", hidden = true)
    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private String delFlag;

    @ApiModelProperty(value = "创建人id", name = "createId", required = true, hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private Long createId;

    @ApiModelProperty(value = "创建人员", name = "createBy", required = true, hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    @ApiModelProperty(value = "创建部门id", name = "createDeptId", required = true, hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private Long createDeptId;

    @ApiModelProperty(value = "创建部门", name = "createDept", required = true, hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private String createDept;

    @ApiModelProperty(value = "创建时间", name = "createTime", required = true, hidden = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新人id", name = "updateId", required = true, hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updateId;

    @ApiModelProperty(value = "更新人", name = "updateBy", required = true, hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    @ApiModelProperty(value = "更新时间", name = "updateTime", required = true, hidden = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @OrderBy()
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
}